<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>修改密码</title>
<link rel="stylesheet" href="${ctx}/resources/layui/css/layui.css"
	media="all"/>
</head>
<body class="childrenBody">
	<form class="layui-form layui-row" style="padding: 10px;">
		<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
			<input type="text" hidden="" name="userid" value="${user.userid}">
			<div class="layui-form-item">
				<label class="layui-form-label">登录名</label>
				<div class="layui-input-block">
					<input type="text" name="loginname" value="${user.loginname}" disabled
						readonly="readonly" class="layui-input layui-disabled">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">旧密码</label>
				<div class="layui-input-block">
					<input type="password" name="pwd" value="" placeholder="请输入旧密码"
						lay-verify="required" class="layui-input pwd">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">新密码</label>
				<div class="layui-input-block">
					<input type="password" name="password" value="" placeholder="请输入新密码"
						lay-verify="required|newPwd" id="newPwd" class="layui-input pwd">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">确认密码</label>
				<div class="layui-input-block">
					<input type="password" value="" placeholder="请确认密码"
						lay-verify="required|confirmPwd" class="layui-input pwd">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="changePwd">立即修改</button>
				</div>
			</div>
		</div>
	</form>
	<script type="text/javascript" src="${ctx}/resources/layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['element','layer','form'],function(){
			var $ = layui.$;
			var layer = layui.layer;
			var form = layui.form;
			//添加验证规则
			form.verify({
				newPwd : function(value, item) {
					if (value.length < 6) {
						return "密码长度不能小于6位";
					}
				},
				confirmPwd : function(value, item) {
					if (!new RegExp($("#newPwd").val()).test(value)) {
						return "两次输入密码不一致，请重新输入！";
					}
				}
			})
			form.on("submit(changePwd)",function(data){
				$.post("${ctx}/user/changePwd.action",data.field,function(result){
					console.log(result);
					layer.msg(result.message);
				})
				return false;
			});
		});
		
	</script>
</body>
</html>